<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\common\IdentitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '身份证验证页面';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h1 class="box-title"><?= $this->title; ?></h1>
            </div>
            <div class="box-body table-responsive">

                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    //重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                            'visible' => FALSE, // 不显示#
                        ],
                        [
                            'attribute' => 'user_id',
                            'label' => '提交用户',
                            'value' => function ($model) {
                                if (empty($model->member->username)) {
                                    return $model->member->mobile;
                                }
                                return $model->member->username;
                            },
                        ],
                        [
                            'attribute' => 'real_name',
                            'value' => function ($model) {
                                return $model->real_name;
                            },
                        ],
                        'code',
                        [
                            'label' => '状态',
                            'value' => function ($model) {
                                $status = ['未通过', '审核中', '审核通过'];
                                if (empty($status[$model->status])) {
                                    return '订单审核未知状态';
                                }

                                return $status[$model->status];
                            },
                        ],
                        [
                            'label' => '提交日期',
                            'format' => 'raw',
                            'value' => function ($model) {
                                $a = Html::tag('p', date("Y-m-d", $model->created_at),
                                    ['class' => 'text text-sm']);

                                return $a;
                            },
                        ],
                        [
                            'label' => '操作',
                            'format' => 'raw',
                            'value' => function ($model) {
                                $status = ['未通过', '审核中', '审核通过'];
                                if ($model->status=='1') {
                                    return
                                        Html::a('审核', ['tf-futures/identity/ajax-edit', 'id' => $model->id], [
                                        'class' => 'btn btn-primary btn-sm',
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                }else{
                                    return '';
                                }

                            },
                        ],
                        // ['class' => 'yii\grid\ActionColumn'],
                    ],
                ]); ?>
            </div>
        </div>
